<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Employee extends CI_Controller {
            public function __construct(){
                        parent::__construct();
                      $this->load->model(array("employeemodel"));
                }

	public function index()
	{
		
    $data=array();

		load($this->db,$this->session,$this->load,"employee","index",$data);
	}


/* $page = isset($_POST['page']) ? intval($_POST['page']) : 1;
    $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
    if($page==1){
      $page=0;
    }
   $arr["total"]=$this->customermodel->get_num();
   $arr["rows"]=$this->customermodel->get_cuss($page,$rows);
   $str=json_encode($arr);
   echo $str;*/


  public function get_emp(){
    $page = isset($_POST['page']) ? intval($_POST['page']) : 1;
    $rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;
    if($page==1){
      $page=0;
    }
    $arr["total"]=$this->employeemodel->get_num();
   $arr["rows"]=$this->employeemodel->get_emps($page,$rows);
   
   $str=json_encode($arr);
   echo $str;

  }

public function adddb(){
   $arr=$_REQUEST;
    $arr['time']=time();
    $arr['del']=0;
    if($this->db->insert("employee",$arr)){
       success();
    }else{
       ajaxfail();
    }
}


public function edit(){
  $id=$this->input->get("id");
  $arr=$this->input->post();
    $arr['time']=time();
      $this->db->where('id',$id);
      if($this->db->update('employee',$arr)){
              success();    
        }else{
             ajaxfail();
        }
}


  public function del(){
            
    $id = intval($_REQUEST['id']);
    $tmp=0;	
    $sql="update employee set del=1  where id=$id";
    if($this->db->query($sql)){
      success();
    }else{
ajaxfail();
    }
   }


}
